import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from "vuex-persistedstate"


Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    userPower: 0,
    userName: '',
    userId: 0,
    userStatus: 0
  },
  mutations: {
    increment(state) {
      state.counter++
    },
    assignPower(state,payload) {
      state.userPower = payload
    },
    assignUserName(state,payload) {
      state.userName = payload
    },
    assignUserId(state,payload) {
      state.userId = payload
    },
    assignUserStatus(state,payload) {
      state.userState = payload
    }
  },
  actions: {},
  // 持久化插件 将veux的数据存储到浏览器
  plugins: [createPersistedState()]
})

export default store

